
#include "PCA_USART.H"



void GPIO_USART1_Init()
{
	GPIO_InitTypeDef GPIO_USART1;
	
	GPIO_USART1.Mode = GPIO_PullUp;
	GPIO_USART1.Pin = GPIO_Pin_1|GPIO_Pin_0;
	GPIO_Inilize(GPIO_P3,&GPIO_USART1);


}

void USART1_Init(void)
{
	COMx_InitDefine USART1_Str;
	
	USART1_Str.UART_Mode = UART_8bit_BRTx;			//模式,         UART_ShiftRight,UART_8bit_BRTx,UART_9bit,UART_9bit_BRTx
	USART1_Str.UART_BRT_Use = BRT_Timer2;		//使用波特率,   BRT_Timer1,BRT_Timer2
	USART1_Str.UART_BaudRate = 9600;		//波特率,       ENABLE,DISABLE
	USART1_Str.Morecommunicate = ENABLE;	//多机通讯允许, ENABLE,DISABLE
	USART1_Str.UART_RxEnable = ENABLE;		//允许接收,   ENABLE,DISABLE
	USART1_Str.BaudRateDouble = DISABLE;		//波特率加倍, ENABLE,DISABLE
	USART1_Str.UART_Interrupt = ENABLE;		//中断控制,   ENABLE,DISABLE
	USART1_Str.UART_Polity = PolityHigh;		//优先级,     PolityLow,PolityHigh
	USART1_Str.UART_P_SW = UART1_SW_P30_P31;			//切换端口,   UART1_SW_P30_P31,UART1_SW_P36_P37,UART1_SW_P16_P17(必须使用内部时钟)
	USART1_Str.UART_RXD_TXD_Short = DISABLE;		//内部短路RXD与TXD, 做中继, ENABLE,DISABLE
	
	
	USART_Configuration(USART1,&USART1_Str);
	GPIO_USART1_Init();

}



u8 USART1_Read(void)
{
 u8 dat;
	dat = SBUF;
	return dat;
}


